package com.geek.ch06.mapper;

import com.geek.entity.mark.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface UserMapper {

    @Select("select * from user where id = #{id}")
    User getUserById(int id);

    // 3：性别和姓名非空查询，且id in(10,20,30)  script脚本
    @Select(
            "<script>" +
                    "select * from user " +
                        "<where>" +
                            "<if test='name != null and name != \"\"'> " +
                                "and name like concat('%', #{name}, '%') " +
                            "</if>" +
                            "<if test='gender != null and gender != \"\"'> " +
                                "and gender = #{gender} " +
                            "</if>" +
                        "</where>" +
                    "</script>"
    )
    List<User> selectUserByGenderAndName(@Param("gender") String gender,
                                         @Param("name") String name);
}
